<template>
  <router-view />
</template>

<script setup>
import { onMounted } from 'vue'
import { initThemeConfig, getThemeConfig, setThemeConfig, themes } from '@/utils/theme'

// App根组件

// 组件挂载后初始化主题
onMounted(() => {
  // 初始化主题设置
  const currentTheme = getThemeConfig() || 'blue'
  
  // 确保使用蓝色主题作为默认值
  if (currentTheme !== 'blue' && !localStorage.getItem('theme')) {
    setThemeConfig('blue')
  } else {
    setThemeConfig(currentTheme)
  }
  
  // 设置根元素CSS变量，确保主题色正确
  const themeObj = themes.find(item => item.name === currentTheme) || themes.find(item => item.name === 'blue')
  if (themeObj) {
    document.documentElement.style.setProperty('--primary-color', themeObj.color)
  }
})
</script>

<style lang="scss">
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
}

#app {
  font-family: 'Microsoft YaHei', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  width: 100%;
}
</style> 